//
//  TCLYPaySucceedViewController.m
//  YuErmuYing
//
//  Created by LYang on 16/9/13.
//  Copyright © 2016年 Tiancheng. All rights reserved.
//
/********************************************************************这个界面是购买支付成功后展示界面 会展示订单的金额以及支付时间************************************************************************************************************************************/
#import "TCLYPaySucceedViewController.h"
#import "Macros.h"
#import "Masonry.h"
#import "TCLYHomeModel.h"
#import "TCLYUser.h"

@interface TCLYPaySucceedViewController ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bgViewHeight;
@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UIImageView *succeedImageView;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UIButton *homeBtn;
@property (nonatomic, strong)TCLYHomeModel * homeModel;

@end

@implementation TCLYPaySucceedViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.view.backgroundColor = bgColor;
    self.bgView.backgroundColor = bgColor;
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(createView) name:@"paySucceedBy" object:nil];
    NSLog(@"%@",self.parameterStr);
    
    self.homeModel = [[TCLYHomeModel alloc] init];
    NSDictionary * dic = [NSDictionary dictionaryWithObjectsAndKeys:self.parameterStr,@"id", nil];
    
    [self.homeModel paySucceedParameter:dic];
    if (screenHeight >= 667.0) {
        self.bgViewHeight.constant = screenHeight+44;
    }else{
        self.bgViewHeight.constant = 667.0;
    }    
}

-(void)createView{
    self.succeedImageView.layer.cornerRadius = 55;
    self.succeedImageView.layer.masksToBounds = YES;
    self.succeedImageView.image = [UIImage imageNamed:@"paySuccess"];
    self.priceLabel.text = [NSString stringWithFormat:@"本单金额: %@",self.homeModel.paySucceedDic[@"total"]];
    self.timeLabel.text = [NSString stringWithFormat:@"订单时间: %@",self.homeModel.paySucceedDic[@"time"]];
    [self.homeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.homeBtn setTitle:@"返回首页" forState:UIControlStateNormal];
    self.homeBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    self.homeBtn.backgroundColor = btnColor;
    self.homeBtn.layer.cornerRadius = 5;
    self.homeBtn.layer.masksToBounds = YES;
    
}
-(IBAction)homeBtnAction:(id)sender{
    if (self.isHome) {
        self.navigationController.navigationBarHidden = YES;
        self.tabBarController.tabBar.hidden = YES;
        [self.navigationController popToRootViewControllerAnimated:YES];
    }else{
        self.navigationController.navigationBarHidden = NO;
        self.tabBarController.tabBar.hidden = NO;
        [self.navigationController popToRootViewControllerAnimated:YES];
    }
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
